<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
  
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Fly社区</title>
    <link rel="stylesheet" href="//at.alicdn.com/t/font_001z27klwvobt9.css">
    <link rel="stylesheet" href="/Bbs/Public/css/layui.css">
    <link rel="stylesheet" href="/Bbs/Public/css/global.css">
    <script src="/Bbs/Public/layui.js"></script>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    
  </head>
  <body>
    <div class="header">
      <div class="main">
        <a class="logo" href="<?php echo U('home/index/index');?>" title="Fly">Fly社区</a>
        <div class="nav">
          <a href="/jie/">
            <i class="iconfont icon-wenda"></i>问答</a>
          <a href="/case/2016/">
            <i class="iconfont icon-iconmingxinganli" style="top: 2px;"></i>案例</a>
          <a href="http://www.layui.com/">
            <i class="iconfont icon-ui"></i>框架</a>
        </div>
        <?php if (!isset($_SESSION['nikename'])) { ?>
          <div class="nav-user">
            <a class="unlogin" href="<?php echo u('home/Enter/index');?>">
              <i class="iconfont icon-touxiang"></i>
            </a>
            <span>
              <a href="<?php echo u('Home/Enter/index');?>">登入</a>
              <a href="<?php echo u('Home/Reg/index');?>">注册</a>
            </span>
            <p class="out-login">
              <a href="<?php echo U('home/enter/qqlogin');?>" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" class="iconfont icon-qq" title="QQ登入"></a>
              <a href="http://fly.layui.com:8098/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" class="iconfont icon-weibo" title="微博登入"></a>
            </p>
          </div>
       <?php  } else { ?> 
          <div class="nav-user">
            <a class="avatar" href="<?php echo u('home/cen/user');?>">
              <img class="img" src="/Bbs/<?php echo $_SESSION['face']; ?>">
              <cite><?php echo $_SESSION['nikename'] ?></cite></a>
            <div class="nav">
              <a href="<?php echo u('home/cen/index');?>">
                <i class="iconfont icon-shezhi"></i>设置</a>
              <a href="<?php echo u('home/cen/quit');?>">
                <i class="iconfont icon-tuichu" style="top: 0; font-size: 22px;" onclick="javascript:if(confirm('确定要退出吗？')){return true;}return false"></i>退出</a>
            </div>
          </div>
        <?php } ?>
      </div>
    </div>
    <div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
            <h1>
                <?php echo $arr['title'] ?>
            </h1>
            <div class="fly-tip fly-detail-hint" data-id="6503">
                <span>
                    <?php echo $arr['status'] ?>
                </span>
                <div class="fly-list-hint">
                    <i class="iconfont" title="回答">
                        
                    </i>
                    <?php echo $arr['answer_num'] ?>
                    <i class="iconfont" title="人气">
                        
                    </i>
                    <?php echo $arr['view_num'] ?>
                </div>
            </div>
            <div class="detail-about">
                <a class="jie-user" href="<?php echo U('home/Cen/hone',array('id'=>$arr['uid']));?>">
                    <img src="/Bbs/<?php echo $arr['face'] ?>" alt="心怀">
                    <cite>
                        <?php echo $arr['nikename'] ?>
                        <em>
                            发布于<?php echo $arr['create_time'] ?>
                        </em>
                    </cite>
                </a>
                <div class="detail-hits" data-id="6503">
                    <span style="color:#FF7200">
                        悬赏：<?php echo $arr['kiss'] ?>飞吻
                    </span>
                </div>
            </div>
            <div class="detail-body photos" style="margin-bottom: 20px;">
                <?php echo htmlspecialchars_decode($arr['content']) ?>
            </div>
            <a name="comment">
            </a>
            <h2 class="page-title">
                热忱回答
                <span>
                    （
                    <em id="jiedaCount">
                        <?php echo count($data) ?>
                    </em>
                    ）
                </span>
            </h2>
            <ul class="jieda photos" id="jid">
            <?php foreach ($data as $v) { ?>
                <li data-id="<?php echo $v['id'] ?>" class="zzz">
                  <a name=""></a>
                  <div class="detail-about detail-about-reply">
                    <a class="jie-user" href="<?php echo U('home/Cen/hone',array('id'=>$v['uid']));?>">
                      <img src="/Bbs/<?php echo $v['face'] ?>" alt="<?php echo $v['nikename'] ?>" layer-index="">
                      <cite>
                        <i><?php echo $v['nikename'] ?></i>
                      </cite>
                    </a>
                    <div class="detail-hits answer<?php echo $v['id'] ?>">
                      <span><?php echo $v['create_time'] ?></span>
                    </div>

                   <?php if ($arr['cn']==1) { if($v['status']==1){ ?> 
                    <i class="iconfont icon-caina" title="最佳答案"></i>
                   <?php } } ?>  
                  </div>
                  <div class="detail-body jieda-body"><?php echo htmlspecialchars_decode($v['content']) ?></div>
                  
                  <div class="jieda-reply">
                    <span class="jieda-zan <?php if ($v['stt']) { echo "zanok";} ?>" you="<?php if ($v['stt']) { echo "1";}else{echo "0"; } ?>" type="zan" id="zhan" name="<?php echo $v['id'] ?>">
                      <i class="iconfont icon-zan"></i>
                      <em><?php echo $v['zan'] ?></em>
                    </span>
                    <span type="reply" class="reqweqe" name="<?php echo $v['nikename'] ?>" lke="<?php echo $v['uid'] ?>">
                      <i class="iconfont icon-svgmoban53" ></i>回复</span>
                    <?php if ($arr['uid']==$_SESSION['id'] && $v['uid']!=$_SESSION['id'] && $arr['cn']==0) { ?>
                    <div class="jieda-admin">
                      <span class="layui-btn layui-btn-warm cn" uid="<?php echo $v['id'] ?>">
                        采纳
                      </span>
                    </div>
                    <?php  } ?>  
                  </div>
                  
                  
                </li>

           <?php } ?>
                
            </ul>
            <div class="layui-form layui-form-pane">
                <form method="post">
                    <div class="layui-form-item layui-form-text">
                        <div class="layui-input-block">
                            <textarea id="L_content" name="content" placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;">
                            </textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <input type="hidden" name="jid" value="6503">
                        <button class="layui-btn" lay-filter="qw" lay-submit="">
                            提交回答
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="edge">
        <h3 class="page-title">
            最近热帖
        </h3>
        <ol class="fly-list-one">
          <?php foreach ($list as $v) { ?>
            <li>
                <a href="<?php echo U('home/publish/issue',array('id'=>$v['id']));?>">
                    <?php echo $v['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    <?php echo $v['view_num'] ?>
                </span>
            </li>
         <?php } ?>
            
        </ol>
        <div style="margin-bottom: 20px;">
            <a href="http://layim.layui.com/?from=fly" target="_blank">
                <img src="http://cdn.layui.com/upload/2016_12/168_1481128213193_98863.png"
                style="width: 100%;" alt="layim下载">
            </a>
        </div>
        <h3 class="page-title">
            近期热议
        </h3>
        <ol class="fly-list-one">
        <?php foreach ($ans as $v) { ?>
          <li>
                <a href="<?php echo U('home/publish/issue',array('id'=>$v['id']));?>">
                    <?php echo $v['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    <?php echo $v['answer_num'] ?>
                </span>
            </li>
       <?php } ?>
            
        </ol>
    </div>
</div>
    <script>
    layui.use(['form', 'layedit'], function(){
      var form = layui.form()
      ,layer = layui.layer
      ,layedit = layui.layedit;
      //图片上传（要做编辑器的前面设置）
      layedit.set({
        uploadImage: {
          url: "<?php echo U('home/publish/upload');?>" //接口url
          ,type: 'post' //默认post
        }
      })
      
      //构建一个默认的编辑器
       index = layedit.build('L_content');

       //自定义
       // layedit.build('L_content', {
       //    tool: ['face', 'image', 'link', 'code', 'yulan']
       //  });   
      //回复
      $(".reqweqe").click(function(event) {
        aaa = $(this).attr('lke');
        //alert(aaa);
        bbbb = layedit.getText(index);
        content ='@ <a href="<?php echo U("home/cen/hone");?>?id='+aaa+'">';
        content += $(this).attr('name');
        content +='</a><span>&nbsp;</span>';
        content +=bbbb;
        $('#L_content').text(content); 
        index = layedit.build('L_content');
      });

      form.on('submit(qw)', function(data){
        // id = <?php  $a = isset($_SESSION['id'])? $_SESSION['id']: 'false'; echo $a ?>;

        // if (!id){
        //   alert(999)
        //   layer.msg("请登录后再发表评论", {icon: 5});
        //   return false;
        // }
        // alert(88)
        content = layedit.getContent(index);
        if(content.length<5){
          layer.msg("内容必须大于5个字符", {icon: 5});
          return false;
        }else{
          data.field.content = content;
          data.field.qid = <?php echo $arr['id'] ?>;
          $.ajax({
            url: "<?php echo U('home/publish/answer');?>",
            type: 'POST',
            dataType: 'json',
            data: data.field,
          })
          .done(function(arr) {
            // document.write(arr);

             if(arr.error==1){
                layer.msg(arr.info, {icon: 5});
           }else{
                layer.msg(arr.info, {icon: 6});
                $("#jid").append('<li data-id="'+arr.id+'"><a name=""></a><div class="detail-about detail-about-reply"><a class="jie-user"href=""><img src="/Bbs/'+arr.face+'"alt="eqew"layer-index="0"><cite><i>'+arr.nikename+'</i></cite></a><div class="detail-hits"><span>'+arr.create_time+'</span></div></div><div class="detail-body jieda-body">'+arr.content+'</div><div class="jieda-reply"><span class="jieda-zan "type="zan"><i class="iconfont icon-zan"></i><em>'+arr.zan+'</em></span><span type="reply"><i class="iconfont icon-svgmoban53"></i>回复</span></div></li>');
                $('#L_content').text('');
                index = layedit.build('L_content');
           }
          })
          .fail(function() {
            console.log("error");
            // layer.msg("数据传输失败", {icon: 5});
          })
          return false;
        }
      });
      //点赞
      $('.jieda-zan').click(function(event) {
        // $("#authCode").attr("is-ok")
        if ($(this).attr("you")!=1) {
          $(this).addClass('zanok');
          $(this).attr("you","1");
        }else{
          $(this).removeClass('zanok');
          $(this).attr("you","0");
        }
        zhan = $(this).attr('name');
        // $(this).children('em').text(10);
        cccc = $(this)
        $.ajax({
            url: "<?php echo U('home/publish/zan');?>",
            type: 'POST',
            dataType: 'json',
            data: {data:zhan},
          })
          .done(function(aaaa) {
            // alert(aaaa.zan);
            cccc.children('em').text(aaaa.zan);
          })
          .fail(function() {
            console.log("error");
          });
        // className="jieda-zan zanok";
        // setAttribute("classname","jieda-zan zanok");
        // 
      });
      //采纳
      $('.cn').click(function(event) {
        qid =<?php echo $arr['id'] ?>;
        aid =$(this).attr('uid');
         ccc=$(this);
        $.ajax({
          url: "<?php echo U('home/publish/cn');?>",
          type: 'POST',
          dataType: 'json',
          data: {qid:qid,aid:aid},
        })
        .done(function(sss) {
          if (sss==1) {
            // alert(sss);
         ccc.parents('.zzz').children('.detail-about').append('<i class="iconfont icon-caina" title="最佳答案"></i>');
         $('.cn').hide();
          };
        })
        .fail(function() {
          console.log("error");
        })
      });
    });

</script>

    <div class="footer">
      <p>
        <a href="http://fly.layui.com/">Fly社区</a>2016 &copy;
        <a href="http://www.layui.com/">layui.com</a></p>
      <p>
        <a href="http://fly.layui.com/jie/3147.html" target="_blank">产品授权</a>
        <a href="http://fly.layui.com/jie/4536.html" target="_blank">获取Fly社区模版</a>
        <a href="http://fly.layui.com/jie/2461.html" target="_blank">微信公众号</a></p>
    </div>

  </body>

</html>